from typing import Optional, Union

from pydantic import BaseModel


class ApiTaskTemplateBean(BaseModel):
    config_id: Optional[str] = None
    id: Optional[Union[int, str]] = None
    flow_id: Optional[str] = None
    description: Optional[str] = None

    is_scheduled: Optional[bool] = False
    scheduled_interval_minutes: Optional[int] = None
    scheduled_period_minutes: Optional[int] = None
    scheduled_start_time: Optional[str] = None

    def to_dict(self):
        return {
            "id": self.id,
            "config_id": self.config_id,
            "flow_id": self.flow_id,
            "description": self.description,
            "is_scheduled": self.is_scheduled,
            "scheduled_interval_minutes": self.scheduled_interval_minutes,
            "scheduled_start_time": self.scheduled_start_time,
        }
